<?php

namespace App\Observers;

use App\Models\GroupGood;
use Illuminate\Support\Facades\Redis;

class GroupGoodObserver
{
    /**
     * Handle the GroupGood "created" event.
     *
     * @param  \App\Models\GroupGood  $groupGood
     * @return void
     */
    public function created(GroupGood $groupGood)
    {
        for ($i=0;$i<$groupGood->limit_quantity;$i++){
            Redis::lpush('group_goods'.$groupGood->id,1);
        }
    }

    /**
     * Handle the GroupGood "updated" event.
     *
     * @param  \App\Models\GroupGood  $groupGood
     * @return void
     */
    public function updated(GroupGood $groupGood)
    {
        //
    }

    /**
     * Handle the GroupGood "deleted" event.
     *
     * @param  \App\Models\GroupGood  $groupGood
     * @return void
     */
    public function deleted(GroupGood $groupGood)
    {
        //
    }

    /**
     * Handle the GroupGood "restored" event.
     *
     * @param  \App\Models\GroupGood  $groupGood
     * @return void
     */
    public function restored(GroupGood $groupGood)
    {
        //
    }

    /**
     * Handle the GroupGood "force deleted" event.
     *
     * @param  \App\Models\GroupGood  $groupGood
     * @return void
     */
    public function forceDeleted(GroupGood $groupGood)
    {
        //
    }
}
